package com.shudes.game;

import java.util.*;

import com.shudes.util.*;

public class Rank extends EnumeratedType {

	public static final Rank TWO = new Rank(2L,"2"); 
	public static final Rank THREE = new Rank(3L, "3"); 
	public static final Rank FOUR = new Rank(4L,"4"); 
	public static final Rank FIVE = new Rank(5L,"5"); 
	public static final Rank SIX = new Rank(6L,"6"); 
	public static final Rank SEVEN = new Rank(7L,"7"); 
	public static final Rank EIGHT = new Rank(8L, "8"); 
	public static final Rank NINE = new Rank(9L, "9"); 
	public static final Rank TEN = new Rank (10L, "T"); 
	public static final Rank JACK = new Rank (11L, "J"); 
	public static final Rank QUEEN = new Rank(12L, "Q"); 
	public static final Rank KING = new Rank(13L, "K"); 
	public static final Rank ACE = new Rank(14L, "A"); 

	protected static Map<Long,Rank> idMap;
	protected static Map<String, Rank> descriptionMap;
	
	protected Rank(Long id, String description) {
		super(id, description);
		
		if(Rank.idMap==null)  
			Rank.idMap = new HashMap<Long, Rank>(); 
		
		if(Rank.descriptionMap==null) 
			Rank.descriptionMap = new HashMap<String, Rank>(); 
		
		idMap.put(id, this);				
		descriptionMap.put(description, this); 		
	}
	
	public static Rank byId(Long id) { 
		return idMap.get(id); 
	}
	
	public static Rank byName(String name) {
		return descriptionMap.get(name); 
	}
	
	public static Set<Rank> getAll() { 
		return new HashSet<Rank>(idMap.values());
	}


}
